{include file="common/head"}
<head>
    <title>{$type_name}管理x</title>

    <style>
        a{text-decoration:none;}
        input{display:initial!important;}
    </style>
</head>
<body >
<div class="container-fluid">
    <form action="/index.php/customer/index/type/2" method="post">
        <div class="row" id="query_bar" style="height: 50px;line-height: 50px;">
            <div class="col-2" style="text-align: left;line-height: 50px;font-size: 2rem;" >
                {$type_name}管理 {$list.total}人
                <input type="hidden" name="show_grid" id="show_grid" value="{$show_grid}" />
                <button type="button" class="btn btn-sm btn-primary" id="show_grid_change">
                    {if $show_grid!=1}
                        <span class="bi-grid"></span>
                    {else}
                        <span class="bi-table"></span>
                    {/if}
                </button>                
            </div>
            <div class="col-10">
            <label for="dept_id" >店铺：</label>
            <select name="dept_id" class="form-control" style="width:140px;display:initial;">
                <option value="">所有店铺</option>
                {foreach $shop_list as $dept}
                    <option value="{$dept.id}" {if $dept.id==$dept_id}selected{/if} >{$dept['name']}</option>
                {/foreach}
            </select>

            <label for="name" >姓名：</label>
            <input class="form-control" type="text"  id="name" name="name" value="{$name}" placeholder="姓名" />
            <label for="mobile" >手机：</label>
            <input class="form-control" type="text"  id="mobile" name="mobile" value="{$mobile}" placeholder="手机号码" />
            <button type="button" class="btn btn-warning query" style="vertical-align: middle;" >
                <span class="bi-search" ></span>
            </button>
        
            </div>

        </div>
    </form>


    {if $show_grid==1}
    <div id="cust_grid" style="display: flex;flex-wrap: wrap;">
        {foreach $list['data'] as $k=>$kv}
            <div class="cust_card row" style="width:300px;margin: 10px;box-shadow: 1px 1px 2px #444;padding:4px;">
                <div class="col-5">
                    <image class="goods_image" src="{$kv['image']}" style="width:100%;" />
                </div>
                <div class="col-7">
                    <div>姓名：<c style="color:blue;text-align:center;">{$kv['name']}</c> </div>
                    <div>手机：{$kv['mobile']} </div>
                    <div class="text-center">
                        <a href="/index.php/customer/edit/id/{$kv['id']}/type/2" title="编辑">
                            <button type="button" class="btn btn-sm btn-info" >
                                <span class="bi-pencil">编辑</span>
                            </button> 
                        </a>
                    <button type="buttun" onClick="resetPwd({$kv['id']})" class="btn btn-sm btn-danger" title="重置密码"> 
                        <span class="bi-key"></span>
                    </button>                        
                    </div>
                </div>
            </div>
        {/foreach}
    </div>

    {else}

    <table class="table table-sm table-hover table-striped">
        <thead>
            <th>序x号</th>
            <th>{$type_name}编号</th>
            <th>姓名</th>
            <th>身份证号码</th>
            <th>性别</th>
            <th>年龄</th>
            <th>电话</th>
            <th>地址</th>
            <th>店铺</th>
            <th>照相</th>
            <th>登录</th>
            <th>状态</th>
            <th>
                <button type="button" class="btn btn-sm btn-primary">
                    <a href="/index.php/customer/customer_add/type/2" alt="新学员登记(New Member)"><span class="bi-plus-lg" style="color:white;"></span></a>
                </button>
            </th>
        </thead>
        <tbody>
            {foreach $list['data'] as $k=>$kv}
            <tr>
                <td>{$k+1}</td>
                <td>{$kv['id']}</td>
                <td>{$kv['name']}</td>
                <td>{$kv['id_card']}</td>
                <td>{$kv['sex']}</td>
                <td>{$kv['age']}</td>
                <td>{$kv['mobile']}</td>
                <td>{$kv['address']}</td>
                <td>{$kv['dept_id_name']}</td>
                <td><img src="{$kv['image']}" class="goods_image" style="width:40px;height: 40px;" alt="无相片" /></td>
                <td>{$kv['login_ip']}<br/>{$kv['login_time']}</td>
                <td style="{if $kv['status']>1} color:red; {/if}">{$kv['status_name']}</td>
                <td>
                    <a href="/index.php/customer/edit/id/{$kv['id']}/type/2" title="编辑">
                        <button style="button" class="btn btn-sm btn-info"><span class="bi-pencil"></span></button>
                    </a>

                    <button type="buttun" onClick="resetPwd({$kv['id']})" class="btn btn-sm btn-danger" title="重置密码"> 
                        <span class="bi-key"></span>
                    </button>

<!--                     <a href="/index.php/customer/charge_by_admin/cid/{$kv['id']}" title="充值">
                    <button type="buttun" class="btn btn-sm btn-warning"> 
                        <span class="bi-currency-dollar"></span>
                    </button>
                    </a> -->
              
                </td>
            </tr>
            {/foreach}


        </tbody>    
    </table>
    {/if}
    {include file="common/pagination"}
</div>

</body>

<script type="text/javascript">

  function resetPwd(uid){
    if(!uid) return false;
    layer.confirm('是否确定重置帐号密码?', {btn: ['是的','不了']}, function(){
        $.post('/index.php/customer/resetpwd',{id:uid},function(res){layer.msg(res.msg)})
    }, function(){
        layer.msg("Cancel!");
        return 0;
    });    
  }

  $(document).ready(function(){
    $(".query").on('click',function(){
        var index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2

        $("form").submit();
        layer.close(index);
    }) 

    $("#show_grid_change").on('click',function(){
        val =$("#show_grid").val();
        console.log(val);
        $("#show_grid").val(val*1>0?0:1);
        $('form').submit();
    })

    $(".goods_image").on('click',function(){
        var img = $(this).attr('src');
        if(!img.trim()) return;

        layer.open({
          type: 1,
          title:'',
          closeBtn: 0, //不显示关闭按钮
         // anim: 1,
          time: 5*1000,
          shadeClose: true, //开启遮罩关闭              
          skin: 'layui-layer-rim', 
          content: "<img src='"+img+"' style='height:100%'>"
        });
    })        
  })

</script>


</body>
</html>
